package com.example.liyuefei;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {

    //private Toast Toast;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        Toast.makeText(this, "hello", Toast.LENGTH_LONG).show();
        EdgeToEdge.enable(this);

        //bim's data
        TextView t = findViewById(R.id.texttest);
        EditText ageText=findViewById(R.id.age);
        EditText heightText=findViewById(R.id.height);
        EditText weightText = findViewById(R.id.weight);

        //login's data
        /*
        EditText InputUserName=findViewById(R.id.userName);
        EditText InputPassword=findViewById(R.id.password);
        Button log_in=findViewById(R.id.login);
        TextView result=findViewById(R.id.result);

        log_in.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String user_name = "admin";
                        String pass_word = "admin";

                        String inputUserName = InputUserName.getText().toString();
                        String inputPassword = InputPassword.getText().toString();

                        if(inputUserName.equals(user_name) && inputPassword.equals(pass_word)){
                            result.setText("You have logged in successful!");
                        }else{
                            result.setText("Please try again.");
                        }
                    }
                }
        );
        */


        Button cacul=findViewById(R.id.calcul);
        int x=12;

        cacul.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        int age = Integer.parseInt(ageText.getText().toString());
                        double weight = Double.parseDouble(weightText.getText().toString());
                        int height = Integer.parseInt(heightText.getText().toString());

                        t.setText("The BMI is: " + weight*height*age);
                    }
                }
        );
        int sum;
        sum=10*10;
       // t.setText("Hello I am sending data from Java" + sum);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });
    }
}